<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/4/8
 * Time: 18:53
 */

namespace app\common\model;


use think\Model;
use think\Session;

class IntegralLog extends Model
{

    /**写入经验获取日志
     * @param $type int 获取积分类型1发布话题2评论3提问增加/减少7管理员增加
     * @param $integral int 积分值
     * @param $relation_id int 关联ID
     * @param string $user_id int 用户ID
     * @return false|int
     */
    public function put_log($type,$integral,$relation_id,$user_id=''){
        if($user_id){
            $user_id = $user_id;
        }else{
            $user_id = Session::get('user_info')['userid'];
        }
        $data['type'] =$type;
        $data['integral'] = $integral;
        $data['relation_id'] = $relation_id;
        $data['add_time'] = date('Y-m-d H:i:s');
        $data['user_id'] = $user_id;
        return $this->save($data);
    }
}